# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'config.ui'
#
# Created: Thu Jan 12 15:18:13 2012
#      by: PyQt4 UI code generator 4.8.4
#
# WARNING! All changes made in this file will be lost!

from PyQt4 import QtCore, QtGui
from conffile import Config
import os,sys
from config import config

try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    _fromUtf8 = lambda s: s

class Config_Form(QtGui.QMainWindow):
    closed = QtCore.pyqtSignal()
    
    def __init__(self, parent=None):
        super(Config_Form, self).__init__(parent)
        self.parent = parent
        
    #def setupUi(self):
        self.setObjectName(_fromUtf8("Form"))
        self.resize(480, 275)
        self.widget = QtGui.QWidget(self)
        self.widget.setGeometry(QtCore.QRect(10, 10, 461, 241))
        self.widget.setObjectName(_fromUtf8("widget"))
        self.toolBox = QtGui.QToolBox(self.widget)
        self.toolBox.setGeometry(QtCore.QRect(0, 0, 451, 231))
        font = QtGui.QFont()
        font.setWeight(75)
        font.setBold(True)
        self.toolBox.setFont(font)
        self.toolBox.setObjectName(_fromUtf8("toolBox"))
        self.page_1 = QtGui.QWidget()
        self.page_1.setGeometry(QtCore.QRect(0, 0, 451, 177))
        self.page_1.setObjectName(_fromUtf8("page_1"))
        self.label = QtGui.QLabel(self.page_1)
        self.label.setGeometry(QtCore.QRect(10, 0, 151, 21))
        self.label.setObjectName(_fromUtf8("label"))
        self.label_2 = QtGui.QLabel(self.page_1)
        self.label_2.setGeometry(QtCore.QRect(10, 30, 151, 21))
        self.label_2.setObjectName(_fromUtf8("label_2"))
        self.checkBox = QtGui.QCheckBox(self.page_1)
        self.checkBox.setGeometry(QtCore.QRect(160, 0, 91, 17))
        self.checkBox.setObjectName(_fromUtf8("checkBox"))
        self.checkBox_2 = QtGui.QCheckBox(self.page_1)
        self.checkBox_2.setGeometry(QtCore.QRect(240, 0, 91, 17))
        self.checkBox_2.setObjectName(_fromUtf8("checkBox_2"))
        self.comboBox = QtGui.QComboBox(self.page_1)
        self.comboBox.setGeometry(QtCore.QRect(160, 30, 67, 22))
        self.comboBox.setObjectName(_fromUtf8("comboBox"))
        self.btsave = QtGui.QPushButton(self.page_1)
        self.btsave.setGeometry(10,100, 70, 35)    
        self.toolBox.addItem(self.page_1, _fromUtf8(""))
        self.page_2 = QtGui.QWidget()
        self.page_2.setGeometry(QtCore.QRect(0, 0, 451, 177))
        self.page_2.setObjectName(_fromUtf8("page_2"))
        self.label_3 = QtGui.QLabel(self.page_2)
        self.label_3.setGeometry(QtCore.QRect(10, 0, 441, 171))
        font = QtGui.QFont()
        font.setPointSize(22)
        self.label_3.setFont(font)
        self.label_3.setAlignment(QtCore.Qt.AlignCenter)
        self.label_3.setObjectName(_fromUtf8("label_3"))
        self.toolBox.addItem(self.page_2, _fromUtf8(""))

        self.retranslateUi()
        self.toolBox.setCurrentIndex(0)
        QtCore.QMetaObject.connectSlotsByName(self)
        self.setWindowModality(True)
        
        self.setcenter()
    
    def setcenter(self):
        screen = QtGui.QDesktopWidget().screenGeometry()
        size = self.geometry()
        self.move((screen.width() - self.width())/2, (screen.height() - self.height())/6)

    def retranslateUi(self):
        self.setWindowTitle(QtGui.QApplication.translate("Form", "Setting", None, QtGui.QApplication.UnicodeUTF8))
        self.label.setText(QtGui.QApplication.translate("Form", "Show Error Log Detail   : ", None, QtGui.QApplication.UnicodeUTF8))
        self.label_2.setText(QtGui.QApplication.translate("Form", "Log To File                       :", None, QtGui.QApplication.UnicodeUTF8))
        self.checkBox.setText(QtGui.QApplication.translate("Form", "Show", None, QtGui.QApplication.UnicodeUTF8))
        self.checkBox_2.setText(QtGui.QApplication.translate("Form", "Hidden", None, QtGui.QApplication.UnicodeUTF8))
        self.toolBox.setItemText(self.toolBox.indexOf(self.page_1), QtGui.QApplication.translate("Form", "Advanced", None, QtGui.QApplication.UnicodeUTF8))
        self.label_3.setText(QtGui.QApplication.translate("Form", "Still Development !", None, QtGui.QApplication.UnicodeUTF8))
        self.toolBox.setItemText(self.toolBox.indexOf(self.page_2), QtGui.QApplication.translate("Form", "General", None, QtGui.QApplication.UnicodeUTF8))
        self.comboBox.addItem('No')
        self.comboBox.addItem('Yes')
        self.btsave.setText(QtGui.QApplication.translate("Form", "Save", None, QtGui.QApplication.UnicodeUTF8))
        self.read_setting()
        self.checkBox.connect(self.checkBox, QtCore.SIGNAL("clicked()"), self.cek_state_1)
        self.checkBox.connect(self.checkBox, QtCore.SIGNAL("clicked()"), self.cek_state)
        self.checkBox_2.connect(self.checkBox_2, QtCore.SIGNAL("clicked()"), self.cek_state_2)
        self.checkBox_2.connect(self.checkBox_2, QtCore.SIGNAL("clicked()"), self.cek_state)
        self.btsave.connect(self.btsave, QtCore.SIGNAL("clicked()"), self.write_setting)
        
    def write_setting(self):
        config.write_config(self.comboBox.currentText(), self.cek_state())
        
    def read_setting(self):
        data = config.read_config()
        
        if data.setting[0].show_error_log_detail == 1:
            self.checkBox.setChecked(True)
        if data.setting[0].show_error_log_detail == 0:
            self.checkBox_2.setChecked(True)
        
        if data.setting[0].log_to_file == 1:
            self.comboBox.setCurrentIndex(1)
        elif data.setting[0].log_to_file == 0:
            self.comboBox.setCurrentIndex(0)
        
    def cek_state(self):
        if self.checkBox.isChecked():
            return 1
        elif self.checkBox_2.isChecked():
            return 0
        else:
            return 0
    
    def cek_state_1(self):
        if self.checkBox.isChecked():
            self.checkBox_2.setChecked(False)
        return 1
        
    def cek_state_2(self):
        if self.checkBox_2.isChecked():
            self.checkBox.setChecked(False)
        return 1
"""            
class build(Config_Form):
    def __init__(self, parent=None):
        ui = Config_Form()
        #ui.setupUi()
        ui.show()
        sys.exit(app.exec_())
"""
"""
if __name__ == "__main__":
    
    app = QtGui.QApplication(sys.argv)
    ui = Config_Form()
    ui.setupUi()
    ui.show()
    sys.exit(app.exec_())
    
    
    #app = QtGui.QApplication(sys.argv)
    #myapp = build()
    #sys.exit(app.exec_())
"""    

    

